﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>条码出入库记录</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
        <a title="查看详情" href="javascript:;" lay-event="view"><i class="layui-icon">&#xe615;</i></a>
        @*<a title="退货入库" href="javascript:;" lay-event="back"><i class="layui-icon">&#xe66b;</i></a>*@
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="mCode" placeholder="记录编码" autocomplete="off" class="layui-input" id="mCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="wareHouse" name="wareHouse">
                                    <option value="">发生仓库</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input class="layui-input" placeholder="开始日期" name="sDate" id="sDate" style="margin-right:15px;" autocomplete="off">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" placeholder="结束日期" name="eDate" id="eDate" style="margin-right:15px;" autocomplete="off">
                            </div>
                    
                            <div class="layui-inline layui-show-xs-block">
                                <select id="inOutType" name="inOutType" class="typeClass">
                                    <option value="">出入库类型</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="userSearch-view" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                                @*<button class="layui-btn" id="btn-export"  type="button" onclick="toExcel()"><i class="layui-icon">&#xe601;</i>数据导出</button>*@
                            </div>

                        </form>
                    </div>
      
                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    function toExcel() {

        window.location.href = "../Plan/ExportMaDanExcel?info=1&plCode=2";
    }
    function loadData() {
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , height: 'full-200'   //固定高度-即固定表头固定第一行首行
            , cols: [[ //标题栏
               { field: 'id', title: 'ID', width: 80}
                , { field: 'mCode', align: 'center', title: '记录编码', width: '14%', unresize: true, totalRowText: '合计' }
                , { field: 'outOrderCode', align: 'center', title: '关联单据', width: '14%' }
                , { field: 'inOutTypeName', align: 'center', title: '出入类型', width: '11%' }
                , { field: 'houseName', align: 'center', title: '发生仓库', width: '10%' }
                , { field: 'inBarCodeCount', align: 'center', title: '入库条码数', width: '6%', totalRow: true}
                , { field: 'inWeight', align: 'center', title: '入库重量', width: '6%', totalRow: true }
                , { field: 'outBarCodeCount', align: 'center', title: '出库条码数', width: '6%', totalRow: true }
                , { field: 'outWeight', align: 'center', title: '出库重量', width: '6%', totalRow: true}
                , { field: 'createtime', align: 'center', title: '创建时间', width: '14%' }
                , { field: 'userName', align: 'center', title: '制单人', width: '9%' }
                , { field: 'memo', align: 'center', title: '备注说明', width: '12%' }
                , { field: 'right', align: 'center', title: '操作', toolbar: '#barDemo', width: '5%', fixed: 'right' }
            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
                TablePowerHide();
            }
            , url: "../Bar/GetDataList?dataType=records&condition=" + conditon
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , totalRow: true//开启合并行
            , limits: [20, 30, 50]
            , limit: 20 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
              if (obj.event === 'view') {
                  InfoOpenPage('../Bar/RecordsList?mCode=' + data.mCode+'&inOutType='+data.inOutType, data.mCode + "记录信息", "85%", "90%");
              }
            });

        });
    }
    $(function () {
        WebPowersShow();
        //获取列表
        DictionaryDropDown("piot", "inOutType", "");

        wareInfo("wareHouse");
        loadData();
    })
    layui.use(['laydate'], function () {
        var $ = layui.$;
        var laydate = layui.laydate;
        var nowTime = new Date().valueOf();
        var max = null;
        var start = laydate.render({
            elem: '#sDate',
            trigger: 'click',
            type: 'date',
            format: 'yyyy-MM-dd',
            max: nowTime,
            btns: ['clear', 'confirm'],

            done: function (value, date) {
                endMax = end.config.max;
                end.config.min = date; //最大时间为结束时间的开始值
                end.config.min.month = date.month - 1;
            }
        });
        var end = laydate.render({
            elem: '#eDate',
            trigger: 'click',
            type: 'date',
            max: 4073558400000,
            format: 'yyyy-MM-dd',
            done: function (value, date) {
                if ($.trim(value) == '') {
                    var curDate = new Date();
                    date = { 'date': curDate.getDate(), 'month': curDate.getMonth() + 1, 'year': curDate.getFullYear() };
                }
                start.config.max = date;//最小时间为开始时间的最大值
                start.config.max.month = date.month - 1;
            }
        })
    })

    function doBack(mCode,wareHouse) {
        var info = undefined;
        $.ajax({
            url: "../Bar/BackInWareHouse",
            data: { mCode: mCode, wareHouse: wareHouse },
            dataType: "json",
            type: "POST",
            async: false,
            success: function (data) {

                info = data;
            }
        });
        return info;
    }
</script>